﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class PlayerCardController : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{

    public int ownPlayerLocationIndex;
    public bool isShowCard;

    public void OnPointerDown(PointerEventData eventData)//点击显示所有的牌和分
    {
        if (ownPlayerLocationIndex == GameData.GetInstance().locationIndex 
            && GameRoomModel.GetInstance().RoomState == 1 && isShowCard == false)
        {
            isShowCard = true;
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.GetComponent<Card>().ShowCardTypeValue();
            }

            GameRoomModel.GetInstance().playerDic[ownPlayerLocationIndex].ShowAllCardType();
        }
        else if(ownPlayerLocationIndex == GameData.GetInstance().locationIndex 
            && GameRoomModel.GetInstance().RoomState == 1 && isShowCard)
        {
            isShowCard = false;
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.GetComponent<Card>().ShowCardTypeBack();
            }
            GameRoomModel.GetInstance().playerDic[ownPlayerLocationIndex].ShowShowCardType();
        }
    }

    public void OnPointerUp(PointerEventData eventData)
    {
    }
}
